﻿using System;
using MB.TheBeerHouse.DAL;

namespace MB.TheBeerHouse.BLL.Articles
{
   public abstract class BaseArticleEntity : BaseEntity
   {
      private static ArticlesElement Settings
      {
         get { return Globals.Settings.Articles; }
      }

      protected static bool CachingEnabled
      {
         get { return Settings.EnableCaching; }
      }
      
      protected static ArticlesDataContext GetContext()
      {
         return new ArticlesDataContext(Settings.ConnectionString);
      }      

      protected static void CacheData(string key, object data)
      {
         if (CachingEnabled && data != null)
         {
            Cache.Insert(key, data, null, DateTime.Now.AddSeconds(Settings.CacheDuration), TimeSpan.Zero);
         }
      }
   } 
}
